<?php

namespace Kunfeng\Dify\Model\Datasets;

/**
 * 更新分段请求模型
 */
class UpdateSegmentRequest
{
    private $content;
    private $answer;
    private $question;
    private $enabled;

    public function __construct(array $data = [])
    {
        $this->content = $data['content'] ?? null;
        $this->answer = $data['answer'] ?? null;
        $this->question = $data['question'] ?? null;
        $this->enabled = $data['enabled'] ?? null;
    }

    /**
     * 创建请求
     */
    public static function create(array $data = []): self
    {
        return new self($data);
    }

    /**
     * 设置内容
     */
    public function setContent(?string $content): self
    {
        $this->content = $content;
        return $this;
    }

    /**
     * 设置答案
     */
    public function setAnswer(?string $answer): self
    {
        $this->answer = $answer;
        return $this;
    }

    /**
     * 设置问题
     */
    public function setQuestion(?string $question): self
    {
        $this->question = $question;
        return $this;
    }

    /**
     * 设置启用状态
     */
    public function setEnabled(?bool $enabled): self
    {
        $this->enabled = $enabled;
        return $this;
    }

    // Getters
    public function getContent(): ?string
    {
        return $this->content;
    }

    public function getAnswer(): ?string
    {
        return $this->answer;
    }

    public function getQuestion(): ?string
    {
        return $this->question;
    }

    public function getEnabled(): ?bool
    {
        return $this->enabled;
    }

    /**
     * 转换为数组
     */
    public function toArray(): array
    {
        $data = [];
        
        if ($this->content !== null) {
            $data['content'] = $this->content;
        }
        if ($this->answer !== null) {
            $data['answer'] = $this->answer;
        }
        if ($this->question !== null) {
            $data['question'] = $this->question;
        }
        if ($this->enabled !== null) {
            $data['enabled'] = $this->enabled;
        }

        return $data;
    }
}
